import { Pie } from '@antv/g2plot';
/*
 *@description:产品
 *@Author:@rennan
 *@Date:2024-09-10 10:38:11
 *@version: V1.0.0
*/
<template>
  <!-- 在vue2 中根节点只能有一个 -->
  <div class="category_box">
    <div class="top">
      <div class="top_input">
        <el-input placeholder="请输入内容" prefix-icon="el-icon-search" v-model="userinput">
        </el-input>
      </div>
      <div class="top_select">
        <el-select v-model="value" placeholder="请选择">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
      </div>
      <div class="top_button">
        <el-button type="primary">搜索</el-button>
      </div>
    </div>
    <div class="content">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="date" label="日期" width="180">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="address" label="地址">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
            <el-button type="text" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="footer">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="paginationData.currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="paginationData.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="paginationData.total">
      </el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      // 用户输入的搜索内容
      userinput: '',
      // 用户选择器选择的内容
      value: '',
      //分页数据
      paginationData: {
        currentPage: 1,
        pageSize: 10,
        total: 100
      },
      tableData: [{
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-08',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-06',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-07',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }],
      options: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }, {
        value: '选项3',
        label: '蚵仔煎'
      }, {
        value: '选项4',
        label: '龙须面'
      }, {
        value: '选项5',
        label: '北京烤鸭'
      }],
    }
  },
  methods: {
    handleSizeChange(val) {
      // 当用户选择每页显示多少条的时候触发 并且发送请求获取数据
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },

    handleClick(row){
      console.log(row);
    }
  }
}
</script>
<style lang="less" scoped>
.category_box {
  background-color: #fff;
  height: 90vh;
  padding: 10px;
  border-radius: 10px;

  .top {
    height: 60px;
    display: flex;
    align-items: center;

    .top_select {
      margin: 0 10px;
    }
  }

  .footer {
    height: 50px;
  }
}
</style>